//短信
module.exports = function (app, models, $, db, nm) {
    //发送模版消息
    async function smssend(templateid,phone,templateparams){
        return await $.node.fetch({
            url: `http://cqhuatang.com/SMSServer/smssend`,
            data: {
                appkey:'152312',
                appsecret:'FYWHI6',
                templateid,
                phone,
                extnum:'',
                templateparams
            }
        })
    }
    //待办提醒
    async function dbts(userId,num){
        let user = await models.user.findSync({ id:userId })
        let res = await smssend('1683344307882PlV',user.phone,[num])
        if(res.code) res.errorMsg = '短信发送失败'
        return res
    }
    app.post('/v2/message/dbts', async (req,res) => {
        res.send(await dbts(req.body.userIds,req.body.num))
    })
    return {
        smssend,
        dbts
    }
}